package com.xiaoshi.oauth.login;

import com.xiaoshi.common.MyResUser;
import com.xiaoshi.interfaces.ConstantsGrantType;
import com.xiaoshi.oauth.AbstractCustomTokenGranter;
import com.xiaoshi.oauth.impl.UserDetailLoginServiceImpl;
import org.springframework.security.oauth2.provider.ClientDetailsService;
import org.springframework.security.oauth2.provider.OAuth2RequestFactory;
import org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices;

import java.util.Map;

/**
 * 总后台的 登录
 */
public class WebDeaultPcLoginGranter extends AbstractCustomTokenGranter {
    private UserDetailLoginServiceImpl userService;


    public WebDeaultPcLoginGranter(AuthorizationServerTokenServices tokenServices, ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory, UserDetailLoginServiceImpl userService) {
        super(tokenServices, clientDetailsService, requestFactory, ConstantsGrantType.DEFAULT_LOGIN);
        this.userService = userService;
    }


    @Override
    protected MyResUser userLogin(Map<String, String> parameters) {
        return userService.userLogin(parameters);
    }
}
